import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/home/home.vue'
import Index from '../views/index/index.vue'
import Class from '../views/class/class.vue'
import Code from '../views/code/code.vue'
const hash = createWebHashHistory()

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: hash,
  routes: [
    {
      path: '/',
      component: Home,
      redirect: '/index',
      children: [
        { path: '/index', component: Index },
        { path: '/class', component: Class }
      ]
    },
    {
      path: '/code',
      component: Code
    }
  ],
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  },
})

export default router
